import java.lang.reflect.Method;
import java.util.stream.Stream;

/**
 * @author zhu
 * @date 2024-04-16
 */
public class MainTest01 {
    public static void main(String[] args) {
        Class<UserService> clazz = UserService.class;

        Method[] methods = clazz.getDeclaredMethods();

        Stream<Method> methodStream = Stream.of(methods);

        Stream<Method> orderStream = methodStream.filter(t -> t.isAnnotationPresent(Order.class));

        Stream<Method> sortStream = orderStream.sorted((m1, m2) -> {
            int val1 = m1.getAnnotation(Order.class).value();
            int val2 = m2.getAnnotation(Order.class).value();
            return val1 - val2;
        });
        Stream<String> nameStream = sortStream.map(Method::getName);

        nameStream.forEach(System.out::println);
    }
}